<template>
	<view style="height: calc(100vh - 45px);" class="bg-white padding">
		<view class="padding-bottom">
			加客服微信，备注我要招聘，客服看到后会第一时间加你。由于人数比较多，如果提示被加好友频繁，请耐心等候。
			<!--
			<view class="padding-top-sm">
				也可以关注官方公众号，每日发布最新招聘求职信息。
			</view>
			-->
		</view>
		
		<view class="padding-top">
			<view class="text-center">
				<image style="width:50vw;height: 50vw;" :src="url" mode=""></image>
			</view>
			<view class="flex padding-bottom margin-top" style="line-height: 30px;">
				<view class="flex-treble text-right padding-right">
					客服微信号： {{ wechat }}
				</view>
				<view class="flex-twice text-center">
					<button @tap="copy" data-clipboard-action="copy" :data-clipboard-text="wechat" class="copy-btn cu-btn bg-green">复制</button>
				</view>
			</view>
			<!-- <view class="flex padding-top" style="line-height: 30px;">
				<view class="flex-treble text-right padding-right">
					客服电话：{{phone}} 
				</view>
				<view class="flex-twice text-center">
					<button @tap="phoneCall" class="cu-btn bg-green">拨打</button>
				</view>
			</view> -->
		</view>
		<view class="text-center text-gray" style="position: fixed;bottom: 20px;width:100%">
			因为专注，所以更专业
		</view>
		
		<view class="cu-modal" :class="showModal?'show':''">
			<view class="cu-dialog">
				<view class="cu-bar bg-white justify-end">
					<view class="content">提示</view>
					<view class="action" @tap="showModal = false">
						<text class="cuIcon-close text-red"></text>
					</view>
				</view>
				<view class="padding-xl">
					微信号复制成功，快去微信-添加朋友-搜索框粘贴吧
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import Clipboard from 'clipboard'
	export default {
		data() {
			return {
				wechat: 'zhongLvTech',
				showModal: false,
				url: '../../static/server.png'
			};
		},
		onLoad(option) {
			this.getConfig()
		},
		methods: {
			getConfig(){
				let config = uni.getStorageSync('config')
				if(config){
					this.wechat = config.find(v=>v.parmName=='h5_wechat_cuser').value
					this.url = config.find(v=>v.parmName=='h5_wechat_cuser_url').value
				}
			},
			phoneCall(){
				let phoneNumber = this.phone;
				uni.makePhoneCall({
					phoneNumber
				})
			},
			copy() {
				let _this = this;
				let clipboard = new Clipboard(".copy-btn");
				clipboard.on('success', function() {
					_this.showModal = true;
					setTimeout(()=>{
						_this.showModal = false;
					}, 3000)
				});
				clipboard.on('error', function() {
					_this.showModal = false;
					setTimeout(()=>{
						uni.showToast({
							title: '复制失败'
						})
					}, 500);
				});
			}
		}
	}
</script>
